package config

// Sarama configuration options
var (
	// kafka
	brokers  = []string{"192.168.43.128:9092"}
	version  = ""
	group    = "east1"
	Topics   = []string{"east_money_stock_data"}
	assignor = "range"
	oldest   = true
	verbose  = false
	topic    = "east_money_stock_data"

	// es
	esUrl   = "http://192.168.43.128:9200"
	esIndex = "east_money_index"

	// redis
	addr         = "192.168.43.128:6379"
	password     = ""
	db           = 0
	poolSize     = 4096
	dialTimeout  = 1000
	readTimeout  = 1000
	writeTimeout = 1000
)

type RedisConfig struct {
	Addr         string
	Password     string
	DialTimeout  int
	ReadTimeout  int
	WriteTimeout int
	PoolSize     int
	DB           int
}

type ESConfig struct {
	EsUrl   string
	EsIndex string
}

type KafkaClientConfig struct {
	Brokers  []string
	Version  string
	Group    string
	Topics   []string
	Assignor string
	Oldest   bool
	Verbose  bool
	Topic    string
}

type Config struct {
	KafkaClientConfig *KafkaClientConfig
	RedisConfig       *RedisConfig
	ESConfig          *ESConfig
}

func NewConfig() *Config {
	var conf = new(Config)

	kafkaClientConfig := &KafkaClientConfig{
		Brokers:  brokers,
		Version:  version,
		Group:    group,
		Topics:   Topics,
		Assignor: assignor,
		Oldest:   true,
		Verbose:  false,
		Topic:    topic,
	}
	conf.KafkaClientConfig = kafkaClientConfig

	esConfig := &ESConfig{
		EsUrl:   esUrl,
		EsIndex: esIndex,
	}
	conf.ESConfig = esConfig

	redisConfig := &RedisConfig{
		Addr:         addr,
		Password:     "",
		DialTimeout:  dialTimeout,
		ReadTimeout:  readTimeout,
		WriteTimeout: writeTimeout,
		PoolSize:     poolSize,
		DB:           db,
	}
	conf.RedisConfig = redisConfig
	return conf
}
